package com.egg.common.core.exception;

import com.egg.common.core.enums.ResponseCode;
import com.egg.common.core.model.response.ResponseData;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;

/**
 * @author east
 */
@Slf4j
@Data
@EqualsAndHashCode(callSuper = true)
public class CustomException extends RuntimeException {


    private Integer code;
    private String message;


    public CustomException(ResponseCode rc) {
        super(rc.getMessage());
        this.code = rc.getCode();
        this.message = rc.getMessage();
    }

    public CustomException(ResponseData rd) {
        super(rd.getMsg());
        this.code = rd.getCode();
        this.message = rd.getMsg();
    }

    public CustomException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public CustomException(String message) {
        super(message);
        this.code = ResponseCode.CUSTOM_ERROR.getCode();
        this.message = message;
    }
}